import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutterplugintesttexture/flutterplugintesttexture.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  int id;

  @override
  void initState() {
    super.initState();
    Future.delayed(Duration(seconds: 0)).then((_) async {
      id = await Flutterplugintesttexture.platformVersion;
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    var child;
    if (id == null) {
      child = Text("waiting");
    } else {
      child = Texture(textureId: id);
    }
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Container(
            height: 333,
            width: 333,
            child: child,
          ),
        ),
      ),
    );
  }
}
